package com.yenlien.traceyun.business.controller.response;

import com.yenlien.traceyun.business.entity.BaseSoil;
import com.yenlien.traceyun.business.entity.Warehouse;
import com.yenlien.traceyun.business.entity.WarehousePart;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: bigwangy@sina.com
 * @create: 2020-12-25
 * @description:
 **/
public class WarehouseTree {

    private String id;

    private String warehouseName;

    private List<WarehousePart> parts = new ArrayList<>();

    public List<BaseSoil> getBaseSoilTree() {
        return baseSoilTree;
    }

    public void setBaseSoilTree(List<BaseSoil> baseSoilTree) {
        this.baseSoilTree = baseSoilTree;
    }

    private List<BaseSoil> baseSoilTree = new ArrayList<>();

    public static WarehouseTree create(Warehouse warehouse) {
        WarehouseTree tree = new WarehouseTree();
        tree.setId(warehouse.getId());
        tree.setWarehouseName(warehouse.getName());
        return tree;
    }

    public static List<WarehouseTree> create(List<Warehouse> warehouses) {
        List<WarehouseTree> trees = new ArrayList<>();
        if (warehouses != null && warehouses.size() > 0) {
            for (Warehouse warehouse : warehouses) {
                trees.add(create(warehouse));
            }
        }
        return trees;
    }

    public void addPart(WarehousePart part) {
        this.parts.add(part);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }

    public List<WarehousePart> getParts() {
        return parts;
    }

    public void setParts(List<WarehousePart> parts) {
        this.parts = parts;
    }
}
